
# Targetted decisions are possible vs _all_ other characters and shown are in the Diplomacy View, not the Intrigue View. The taker is in the FROM scope.
#
# filter = [self/court/home_court/vassals/sub_realm/realm/dynasty/all] ('self' MUST be set for decisions targetting only the taker, the other filter types can be set to lessen CPU load)
# ai_target_filter = [self/court/home_court/vassals/sub_realm/realm/dynasty/all] (which characters for which the AI evaluates the decision.)
#	court: all characters in the AI's host court, including prisoners, and characters currently away (wards, prisoners, etc)
#	home_court: all characters in the AI's home court, including prisoners, and characters currently away (wards, prisoners, etc)
#	vassals: direct vassal rulers of the AI's employer
#	sub_realm: all characters below the AI's employer
#	realm: all characters in the same top realm as the AI
#	dynasty: all members of the same dynasty
#	rivals: your rivals plus any character you have an opinion modifier with 'crime = yes' set (the same set of characters the 'is_foe' trigger evaluates)
#	all: all living characters (Avoid if possible. VERY CPU-HEAVY!)
#	

targetted_decisions = {

	castration_decision = {
		filter = court
		ai_target_filter = court

		from_potential = {
			is_ruler = yes
		}
	
		potential = {
			host = { character = FROM }
			prisoner = yes
			is_female = no
			NOT = { trait = eunuch }
		}
		allow = {
			prisoner = yes
		}
		effect = {
			hidden_tooltip = {
				if = {
					limit = { age = 16}
					FROM = {
						character_event = { id = LoR.832 }
					}
				}
				if = {
					limit = { NOT = { age = 16 } }
					FROM = {
						character_event = { id = LoR.834 }
					}
				}
			}
			character_event = { id = LoR.833 tooltip = "EVTTOOLTIPLoR.833" }
			add_trait = eunuch
			opinion = {
				modifier = opinion_castrated_me
				who = FROM
			}
			FROM = {
				if = {
					limit = { NOT = { trait = cruel } }
					random = {
						chance = 5
						add_trait = cruel
						hidden_tooltip = {
							character_event = { id = 38259 }
						}
					}
				}
				piety = -1
			}
			hidden_tooltip = {
				mother = {
					opinion = {
						modifier = opinion_castrated_close_kin
						who = FROM
					}
				}
				father = {
					opinion = {
						modifier = opinion_castrated_close_kin
						who = FROM
					}
				}
				spouse = {
					opinion = {
						modifier = opinion_castrated_close_kin
						who = FROM
					}
				}
				any_child = {
					opinion = {
						modifier = opinion_castrated_close_kin
						who = FROM
					}
				}
				if = {
					limit = {
						FROM = {
							NOT = { dynasty = ROOT }
							NOT = { sibling = ROOT }
						}
					}
					any_sibling = {
						opinion = {
							modifier = opinion_castrated_close_kin
							who = FROM
						}
					}
					any_dynasty_member = {
						opinion = {
							modifier = opinion_castrated_family
							who = FROM
						}
					}
				}
				FROM = {
					remove_opinion = { who = ROOT modifier = opinion_traitor }
					remove_opinion = { who = ROOT modifier = opinion_rebel_traitor }
					remove_opinion = { who = ROOT modifier = opinion_dishonorable }
				}
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
			
			modifier = {
				factor = 0.01
				reverse_opinion = { who = FROM value = 40 }
			}
			modifier = {
				factor = 0.10
				FROM = { trait = kind }
			}
			modifier = {
				factor = 0.80 # Less likely to do it
			}
			modifier = {
				factor = 1.50
				FROM = {
					OR = {
						trait = cruel
						trait = impaler
					}
				}
			}
		}
	}
	
	blind_decision = {
		filter = court
		ai_target_filter = court
	
		from_potential = {
			is_ruler = yes
		}
	
		potential = {
			host = { character = FROM }
			prisoner = yes
			NOT = { trait = blinded }
		}
		allow = {
			prisoner = yes
		}
		effect = {
			hidden_tooltip = {
				FROM = {
					character_event = { id = LoR.830 }
				}
			}
			character_event = { id = LoR.831 tooltip = "EVTTOOLTIPLoR.831" }
			add_trait = blinded
			opinion = {
				modifier = opinion_blinded_me
				who = FROM
			}
			FROM = {
				if = {
					limit = { NOT = { trait = cruel } }
					random = {
						chance = 5
						add_trait = cruel
						hidden_tooltip = {
							character_event = { id = 38259 }
						}
					}
				}
				piety = -1
			}
			hidden_tooltip = {
				mother = {
					opinion = {
						modifier = opinion_blinded_close_kin
						who = FROM
					}
				}
				father = {
					opinion = {
						modifier = opinion_blinded_close_kin
						who = FROM
					}
				}
				spouse = {
					opinion = {
						modifier = opinion_blinded_close_kin
						who = FROM
					}
				}
				any_child = {
					opinion = {
						modifier = opinion_blinded_close_kin
						who = FROM
					}
				}
				if = {
					limit = {
						FROM = {
							NOT = { dynasty = ROOT }
							NOT = { sibling = ROOT }
						}
					}
					any_sibling = {
						opinion = {
							modifier = opinion_blinded_close_kin
							who = FROM
						}
					}
					any_dynasty_member = {
						opinion = {
							modifier = opinion_blinded_family
							who = FROM
						}
					}
				}
				FROM = {
					remove_opinion = { who = ROOT modifier = opinion_traitor }
					remove_opinion = { who = ROOT modifier = opinion_rebel_traitor }
					remove_opinion = { who = ROOT modifier = opinion_dishonorable }
				}
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0.20
				FROM = { trait = kind }
			}
			modifier = {
				factor = 0.50 # Less likely to do it
			}
			modifier = {
				factor = 1
				is_pretender = yes
				FROM = {
					OR = {
						is_pretender = yes
						is_primary_heir = yes
					}
				}
			}
		}
	}
}
